<include file="Public:header" />
<!-- nice-scroll -->
<script src="__PUBLIC__/style/js/plugins/nice-scroll/jquery.nicescroll.min.js" type="text/javascript"></script>
<script type="text/javascript" src="__PUBLIC__/style/js/TableFreeze.js"></script>
<!-- daterangepicker -->
<link href="__PUBLIC__/css/daterangepicker.css" rel="stylesheet">
<script src="__PUBLIC__/js/daterangepicker/daterangepicker.js"></script>
<style>
	body{
		overflow-y: hidden;
	}
	table tr td{min-width: 50px;text-align: center;}
	table tr {height: 50px;}
	#oDivL_tab_Test3{background-color: #fff;z-index: inherit !important;}
	.table{max-width: none;}
	.tabTh{background-color: #fff;}

	#right-sidebar-log{
		width: 50% !important;
		right: -60%;
		background-color: #fff;
	    overflow: hidden;
	    position: fixed;
	    top: 60px;
	    z-index: 1009;
	    bottom: 0;
	    box-shadow: 0px 2px 1px #888888;
	}
	.ibox-span{
		float: left;
		line-height: 30px;
	}
</style>
<script>
$(function(){
	var scroll_width = 10;
	$("#table_div").height(window.innerHeight-$("#table_div").offset().top-$("#tfoot_div").height()-20);
	$(window).resize(function(){
		$("#table_div").height(window.innerHeight-$("#table_div").offset().top-$("#tfoot_div").height()-20);
		$("#oDivL_tab_Test3").height($("#table_div").height()-scroll_width-1).width($("#oTableLH_tab_Test3").width());
		$("#oDivH_tab_Test3").height($("#oTableLH_tab_Test3").height()).width($("#table_div").width()-scroll_width);
	});
	$(".nicescroll").niceScroll({
		cursorcolor: "#999",//#CC0071 光标颜色 
	    cursoropacitymax: 0.4, //改变不透明度非常光标处于活动状态（scrollabar“可见”状态），范围从1到0 
	    touchbehavior: false, //使光标拖动滚动像在台式电脑触摸设备 
	    cursorwidth: scroll_width+"px", //像素光标的宽度 
	    cursorborder: "0", //     游标边框css定义 
	    cursorborderradius: "3px",//以像素为光标边界半径 
	    autohidemode: false, //是否隐藏滚动条 
	    zindex:100,
	    background:"#F3F3F5",//滚动条背景色
	});
	$("#tab_Test3").FrozenTable(2,0,1);
	$("#oDivL_tab_Test3").height($("#table_div").height()).width($("#oTableLH_tab_Test3").width());
	$("#oDivH_tab_Test3").height($("#oTableLH_tab_Test3").height()).width($("#table_div").width());
	$("#oDivF_tab_Test3").css("top",$("#table_div").height());
});
</script>
<div class="wrapper wrapper-content ">
	<div class="row">
		<div class="col-lg-12">
			<include file="Public:alert" />
			<div class="ibox float-e-margins">
				<include file="Public:analytics_left" />
				<input type="hidden" id="type_id" value="{$type_id}">
				<input type="hidden" id="content_id" value="{$content_id}">
				<div class="col-lg-10">
					<div class="ibox-content" style="padding-bottom:10px;border-bottom: none;">
						<form id="searchForm" class="form-group" method="get" style="margin-bottom: 0px;">
							<input type="hidden" name="m" value="examine" />
							<input type="hidden" name="a" value="analytics" />
							<input type="hidden" name="act" id="act" value="index" />
							<input type="hidden" name="content_id" value="<php>echo $content_id = $_GET['content_id'] ? intval($_GET['content_id']) : 1;</php>" />
							<div class="row">
								<div class="col-lg-2">
									<div class="pull-left" >
										<span style="font-size: 18px;color: #000;">
											审批统计分析
										</span>
									</div>
								</div>
								<div class="col-lg-9">
									<ul class="nav pull-left" style="margin:2px 0 0 15px;">
										<li>
											<div class="input-group">
												<input type="text" name="between_date" id="reservation" class="form-control" style="width:300px;"/>
												<i class="glyphicon glyphicon-calendar fa fa-calendar" style="position: absolute;bottom: 10px;right: 24px;top: auto;cursor: pointer;"></i>
											</div>
										</li>
									</ul>
									<ul class="nav pull-left" style="margin:2px 0 0 15px;">
										<li>
											<div class="input-group">
												<select class="form-control input-sm " style="min-width:165px;max-width: 165px;" name="department" id="department" onchange="changeRole()">
													<option class="all" value="all">{:L('ALL')}</option>
													<volist name="departmentList" id="vo">
														<option value="{$vo.department_id}">{$vo.name}</option>
													</volist>
												</select>
											</div>
										</li>
									</ul>
									<ul class="nav pull-left" style="margin:2px 0 0 15px;">
										<li>
											<div class="input-group">
												<select class="form-control input-sm " style="min-width:165px;max-width: 165px;" name="role" id="role" onchange="changeCondition()">
													<option class="all" value="all">{:L('ALL')}</option>
													<volist name="roleList" id="vo">
														<option value="{$vo.role_id}" <if condition="$_GET['role'] eq $vo['role_id']">selected</if>>{$vo.role_name}-{$vo.user_name}</option>
													</volist>
												</select>
											</div>
										</li>
									</ul>
									<div class="pull-left" style="margin-left: 20px;">
										<button type="submit" id="analytics_search" class="btn btn-primary">{:L('SEARCH')}</button>
									</div>
								</div>
								<div class="col-lg-1">
									<div class="pull-right" style="margin-left: 15px;line-height: 40px;">
										<span class="fa fa-download" style="color:#75899D;"></span>
										<a style="color: #75899D;" id="excelExport" href="javascript:void(0);">导出</a>
									</div>
								</div>
							</div>
						</form>
					</div>
					<div class="ibox-content " id="right_height" style="border-top: none;">  
						<div class="th_content" style="position:relative;">
							<div id="table_div" class="nicescroll" >
								<table class="table table-hover table-striped table_thead_fixed table-bordered" id="tab_Test3" >
									<tbody>
										<tr class="tabTh">
											<td style="min-width:170px;padding-left: 15px;text-align: left;">员工</td>
											<td>请假（天）</td>
											<td>报销（元）</td>
											<td>差旅（元）</td>
											<td>出差</td>
											<td>借款（元）</td>
											<td>外勤签到（次）</td>
										</tr>
										<tr class="tabTh">
											<td style="min-width:170px;padding-left: 15px;text-align: left;">合计</td>
											<td>{$examine_total['status_a_total']}</td>
											<td>{$examine_total['status_b_total']}</td>
											<td>{$examine_total['status_c_total']}</td>
											<td>{$examine_total['status_d_total']}</td>
											<td>{$examine_total['status_e_total']}</td>
											<td>{$examine_total['status_f_total']}</td>
										</tr>
										<volist name="role_list" id="vo">
											<tr>
												<td style="padding-left: 15px;text-align: left;">
													<a class="role_info" rel="{$vo.role_id}" href="javascript:void(0)">
													<if condition="$vo['thumb_path']">
														<img class="img-circle" style="width:32px;height:32px;" src="{$vo['thumb_path']}"/>
													<else/>
														<img class="img-circle" style="width:32px;height:32px;" src="__PUBLIC__/img/avatar_default.png"/>
													</if>
													<span>{$vo['full_name']}</span>
													</a>
												</td>
												<td>
													<a target="_blank" href="{:U('examine/index','owner_role_id[value]='.$vo['role_id'].'&create_time[start]='.$start_date.'&create_time[end]='.$end_date.'&type[value]=2'.'&examine_status[value]=2')}">{$vo['status_a']}</a>
												</td>
												<td>
													<a target="_blank" href="{:U('examine/index','owner_role_id[value]='.$vo['role_id'].'&create_time[start]='.$start_date.'&create_time[end]='.$end_date.'&type[value]=3'.'&examine_status[value]=2')}">	{$vo['status_b']}</a>
												</td>
												<td>
													<a target="_blank" href="{:U('examine/index','owner_role_id[value]='.$vo['role_id'].'&create_time[start]='.$start_date.'&create_time[end]='.$end_date.'&type[value]=4'.'&examine_status[value]=2')}">	{$vo['status_c']}</a>
												</td>
												<td>
													<a target="_blank" href="{:U('examine/index','owner_role_id[value]='.$vo['role_id'].'&create_time[start]='.$start_date.'&create_time[end]='.$end_date.'&type[value]=5'.'&examine_status[value]=2')}">	{$vo['status_d']}</a>
												</td>
												<td>
													<a target="_blank" href="{:U('examine/index','owner_role_id[value]='.$vo['role_id'].'&create_time[start]='.$start_date.'&create_time[end]='.$end_date.'&type[value]=6'.'&examine_status[value]=2')}">{$vo['status_e']}</a>
												</td>
												<td>
													<a target="_blank" href="{:U('sign/index','role_id='.$vo['role_id'].'&sign_time='.$between_date)}">{$vo['status_f']}</a>
												</td>
											</tr>
										</volist>
									</tbody>
								</table>
							</div>
							<div id="tfoot_div" class="clearfix">
								<div class="clearfix" id="tfoot_page">
									<if condition="$fields_search || $_GET['field']">
										<span class="pull-left" style="margin-left:25px;margin-top:10px;">本次搜索结果<span style="color:#F8AC59"> {$count} </span>条数据<a href="{:U('contacts/index')}" class="btn" style="background:#fff;border:1px solid #ccc;margin-left:10px;color:#999;" id="clearnumber">清除搜索条件</a></span>
									</if>
									{$page}<include file="Public:listrows" />
								</div>
							</div>
						</div>
						<div class="clearfix"></div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<div class="" style="display:none;" id="dialog-role-info" title="员工信息">
	<div class="spiner-example">
        <div class="sk-spinner sk-spinner-three-bounce">
            <div class="sk-bounce1"></div>
            <div class="sk-bounce2"></div>
            <div class="sk-bounce3"></div>
        </div>
    </div>
</div>
<script type="text/javascript">

	//时间插件  
    $('#reservation').daterangepicker({
        startDate: '{$start_date}', 
        endDate: '{$end_date}',   
        //minDate: '01/01/2012',    //最小时间  
        maxDate : moment(), //最大时间
        showDropdowns : true,  
        showWeekNumbers : false, //是否显示第几周  
        // timePicker : true, //是否显示小时和分钟  
        // timePickerIncrement : 60, //时间的增量，单位为分钟  
        timePicker12Hour : false, //是否使用12小时制来显示时间  
        ranges : {  
            //'最近1小时': [moment().subtract('hours',1), moment()],  
            '今日': [moment().startOf('day'), moment()],  
            '昨日': [moment().subtract('days', 1).startOf('day'), moment().subtract('days', 1).endOf('day')], 
            '上月': [moment().subtract('days', '{$daterange[0][start_day]}'), moment().subtract('days', '{$daterange[0][end_day]}')],
            '本月': [moment().subtract('days', '{$daterange[1][start_day]}'), moment()], 
            '上季度': [moment().subtract('days', '{$daterange[2][start_day]}'), moment().subtract('days', '{$daterange[2][end_day]}')],
            '本季度': [moment().subtract('days', '{$daterange[3][start_day]}'), moment()], 
            '上一年': [moment().subtract('days', '{$daterange[4][start_day]}'), moment().subtract('days', '{$daterange[4][end_day]}')],
            '本年': [moment().subtract('days', '{$daterange[5][start_day]}'), moment()], 
            // '最近7日': [moment().subtract('days', 6), moment()],  
            // '最近30日': [moment().subtract('days', 29), moment()]  
        },  
        opens : 'right', //日期选择框的弹出位置  
        buttonClasses : [ 'btn btn-default' ],  
        applyClass : 'btn-small btn-primary blue',  
        cancelClass : 'btn-small', 
        separator : ' to ',  
        locale : {  
            applyLabel : '确定',  
            cancelLabel : '取消',  
            fromLabel : '起始时间',  
            toLabel : '结束时间',  
            customRangeLabel : '自定义',  
            daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],  
            monthNames: ["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],
            firstDay : 1 ,
            format : 'YYYY-MM-DD', //控件中from和to 显示的日期格式
        },
        "alwaysShowCalendars": true,
        function(start, end, label) {
        	//回调
        	$('#reservation').val(start.format('YYYY-MM-DD HH:mm:ss') + ' - ' + end.format('YYYY-MM-DD HH:mm:ss'))
  			// console.log("New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')");
    	}
    });

	$(".search_time").change(function(){
		var search_year = $('#search_year').val();
		var search_month = $('#search_month').val();
		var type_id = "{$_GET['type_id']}";
		var content_id = "{$_GET['content_id']}";  
		window.location.href="{:U('examine/analytics','&type_id=')}"+type_id+'&content_id='+content_id+'&search_year='+search_year+'&search_month='+search_month+'&department=all&role=all';
	});

	$("#dialog-role-info").dialog({
		autoOpen: false,
		modal: true,
		width: 600,
		maxHeight: 550,
		position: ["center",100]
	});

	$("#excelExport").click(function(){
		swal({   
			title: "确定导出审批统计吗？",
			type: "warning",   
			showCancelButton: true,   
			confirmButtonColor: "#DD6B55",   
			confirmButtonText: "确定",   
			closeOnConfirm: false, 
			animation: "slide-from-top", 
			showLoaderOnConfirm: true
		}, 
		function(){
			var url = "{:U('examine/getanalycurrentstatus')}";
			$.get(url,function(data){
				if (data.data == 0) {
					$("#act").val('excel');
					$("#searchForm").submit();
					swal("数据导出成功！","","success");
					$("#act").val('index');
				} else {
					swal("数据导出失败！","","error"); 
				}
			}, 'json');
		});
	})
	
	$(".role_info").click(function(){
		$role_id = $(this).attr('rel');
		$('#dialog-role-info').dialog('open');
		$('#dialog-role-info').load('{:U("user/dialoginfo","id=")}'+$role_id);
	});

	function changeRole(){
		department_id = $("#department option:selected").val();
		$.ajax({
			type:'get',
			url:'index.php?m=user&a=getrolebydepartment&department_id='+department_id,
			async:true,
			success:function(data){
				options = '<option value="all">{:L('ALL')}</option>';
				if(data.data != null){
					$.each(data.data, function(k, v){
						options += '<option value="'+v.role_id+'">'+v.role_name+"-"+v.user_name+'</option>';
					});
				}
				$("#role").html(options);
				<if condition="$_GET['role']">
				$("#role option[value='{$Think.get.role}']").prop("selected", true);
				</if>
			},
			dataType:'json'});
	}

	<if condition="$_GET['department'] and $_GET['department'] neq 'all'">
	$("#department option[value='{$Think.get.department}']").prop("selected", true); 
	changeRole();
	</if>
	<if condition="$_GET['department'] eq 'all'">
	$("#role option[value='{$Think.get.role}']").prop("selected", true);
	</if>
</script>
<include file="Public:footer" />